package org.ichow.scenegame.core
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	
	/**
	 * ...
	 * @author M.ichow
	 */
	public class Item extends Sprite
	{
		private var _title:String;
		public var url:String;
		
		public var id:String;
		public var des:String;
		public var info:String;
		
		public var continueValue:String;
		public var endValue:String;
		
		private var _icon:String;
		private var _children:Array;
		private var _score:Array;
		private var _mc:MovieClip;
		private var _titleTf:TextField;
		private var _bg:MovieClip;
		
		public var count:int = 0;
		
		public function Item( mc:MovieClip )
		{
			_mc = mc;
			addChild( _mc );
			//
			_titleTf = _mc.getChildByName( "title_txt" ) as TextField;
			_bg = _mc.getChildByName( "bg_mc" ) as MovieClip;
		}
		
		public function get children():Array
		{
			return _children;
		}
		
		public function set children( value:Array ):void
		{
			_children = value;
		}
		
		public function get score():Array
		{
			return _score;
		}
		
		public function set score( value:Array ):void
		{
			_score = value;
		}
		
		public function get icon():String
		{
			return _icon;
		}
		
		public function set icon( value:String ):void
		{
			_icon = value;
			_mc.gotoAndStop( int( _icon ) );
			_mc.addEventListener( MouseEvent.CLICK , onMouseClick );
		}
		
		private function onMouseClick( e:MouseEvent ):void
		{
			dispatchEvent( e );
		}
		
		public function draw():void
		{
			//_bg.graphics.lineStyle(1, 0xFF0000, 1);
			//_bg.graphics.drawRect(-1, -1, _bg.width+1, _bg.height+1);
			_bg.gotoAndStop( 2 );
		}
		
		public function clear():void
		{
			//_bg.graphics.clear();
			_bg.gotoAndStop( 1 );
		}
		
		public function get title():String
		{
			return _title;
		}
		
		public function set title( value:String ):void
		{
			_title = value;
			_titleTf.text = _title;
		}
	
	}

}